import Vue from 'vue'
import storage from '@/localstorage/conf'
import * as OldFn from './user_v1'
import storeOper from './storage_v1'

// 需要兼容老版本
export const isLogined = () => {
	let uInfo = Vue.ls.get(storage.user);
	let oldUid = OldFn.isLogined();

	if (uInfo && uInfo.id) { // 优先用新的方法取uid值
		return true;
	} else {
		if (oldUid) { // 如果有老的uid, 取老的uid并赋值到新的uid上
			let oldUserInfo = storeOper.get(OldFn.LOCAL_USER_INFO);
			Vue.ls.set(storage.user, {
				id: oldUserInfo.id,
				mobile: oldUserInfo.mobile
			});
			return true;
		}
	}
	return false;
}